1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| #include<vector> #include<iostream> #include<stdio.h> #include<queue> #include<cstring> #include<cmath> #include<map> #include<stack> #include<numeric> #include<algorithm> #include<set> using namespace std; #pragma comment(linker, "/STACK:10240000000,10240000000") #define mem(x,y) memset(x,y,sizeof(x)) #define mec(x,y) memcpy(x,y,sizeof(x)) #define debug puts("============") #define eps 1e-5 #define mp(x,y) make_pair(x,y) #define inf 0x3f3f3f3f #define NV 150 #define nit int #define mian main #define ture true #define ll long long #define maxn 100+4 #define sf(x) scanf("%d",&x) #define sff(x,y) scanf("%d%d",&x,&y) #define sfff(x,y,z) scanf("%d%d%d",&x,&y,&z) #define NE 3000 int n; int out[1010]; int main() { while(sf(n),n) { while(sf(out[1]),out[1]) { stack<int>s; int j=n; for(int i=2;i<=n;i++)sf(out[i]); int i=n+1; while(i--) { s.push(out[i]); while(!s.empty()&&s.top()==j)s.pop(),j--; } if(s.empty())puts("Yes"); else puts("No"); } puts(""); } }
|